Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request implements experimental request hedging for storage::AsyncClient::Open() stream-open handshakes. It introduces the HedgedOpenOperation class to manage racing the primary stream-open attempt against delayed speculative attempts, and extracts HedgeLimiter from HedgingThreadPool to enforce connection-wide concurrency and rate limits. Additionally, it refactors OpenObject and OpenStream to support robust cancellation during the stream-open handshake, and adds comprehensive unit tests to verify these new behaviors. I have no feedback to provide as there are no review comments.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #16612 +/- ##
==========================================
+ Coverage 92.78% 92.79% +0.01%
==========================================
Files 2271 2272 +1
Lines 227688 228731 +1043
==========================================
+ Hits 211255 212246 +991
- Misses 16433 16485 +52 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
6e1f7c8 to
687163b
Compare
687163b to
b3ad928
Compare
b3ad928 to
e3c716f
Compare
Extract the connection-wide rate, concurrency, and lifetime hedge limiter out of HedgingThreadPool into internal/hedge_limiter.h so AsyncConnectionImpl can share the same rate/concurrency/total limiter state machine without instantiating a thread pool.
Extends storage_experimental::EnableReadHedgingOption to storage::AsyncClient::Open() (BidiReadObject) so slow initial stream-open handshakes race against up to MaxReadHedgesOption delayed speculative attempts scheduled via CompletionQueue::MakeRelativeTimer without spawning dedicated read or hedging thread pools.
e3c716f to
085a1bc
Compare
085a1bc to
c2f8dbb
Compare
Note
Stacked PR (2 of 2): Stacked on #16613 (
fix(storage): make OpenStream and OpenObject cancellation-safe).9 files, +1,463 / -139): Comparefix/storage-bidi-open-cancel...feat/storage-bidi-open-hedgingmain, its prerequisite commit drops out of this PR automatically.Summary
Extends
storage_experimental::EnableReadHedgingOptiontostorage::AsyncClient::Open()(BidiReadObject) so that slow initial stream-open handshakes are raced against delayed speculative attempts on the gRPCCompletionQueue.Motivation
Opening a
BidiReadObjectstream requires a multi-step handshake (Start()-> initialWrite()-> firstRead()returning object metadata and aBidiReadObjectHandle) and can experience severe tail-latency spikes when an individual subchannel, backend task, or DirectPath/CloudPath route stalls during connection setup or backend routing. Previously,EnableReadHedgingOptiononly hedged synchronousstorage::Client::ReadObject()streams, leavingstorage::AsyncClient::Open()vulnerable to single-attempt open stalls until the per-stream stall timeout (DownloadStallTimeoutOption) expired.Racing the initial
Open()handshake against bounded, delayed speculativeOpen()attempts cutsBidiReadObjectopen tail latency without duplicating any subsequentObjectDescriptor::Read()ranged-read payload transfers or spawning dedicated worker thread pools.Changes
HedgeLimiter(google/cloud/storage/internal/hedge_limiter.h,hedging_thread_pool.h):MaxConcurrentHedgesOption,ReadHedgeRateLimitOption, andMaxTotalHedgesOption) fromHedgingThreadPoolintohedge_limiter.has a verbatim delegation (HedgingThreadPool's API, behavior, and existinghedging_thread_pool_test.ccgate/rollback/contention coverage are preserved unchanged) soHedgingThreadPoolandAsyncConnectionImplshare identical budget enforcement without couplingAsyncConnectionImplto synchronous worker thread pools.Open()Hedging (google/cloud/storage/internal/async/connection_impl.{h,cc}):HedgeLimiterandHedgedReadMetricsinconnection_impl.hand initializes both (capacity = rate_limit1-second burst, matchingStorageConnectionImpl, andstorage.read_hedging.{hedges_dispatched,hedge_won}) onAsyncConnectionImplwhenEnableReadHedgingOptionis enabled at client construction time.HedgedOpenOperationusingCompletionQueue::MakeRelativeTimer(zero dedicated hedging/read thread pools,{null_promise_t{}}promise initialization, move-only RAIIHedgeSlotconcurrency release, andkHedgeRetryMinDelay = 10mscontention floor) to race the primaryOpenStreamFactoryattempt against up toMaxReadHedgesOptionspeculative attempts spaced byReadHedgeDelayOption, propagatingCallContextacross timer and completion callbacks.OpenObject/OpenStreamcancellation path) and pending hedge timers as soon as any attempt wins; aborts stalled sibling attempts immediately on permanent non-kCancelledrejections from any attempt (primary or hedge, since unlike mid-stream syncHedgedObjectReadSourceeveryOpen()attempt sends the identical initial request), while allowing in-flight hedges to rescue primaries cancelled by per-stream stall timeouts (kCancelled); and drains active attempts cleanly on caller.cancel().TrackedFeature::kReadHedging(x-goog-storage-cpp-features) strictly onHedgedOpenOperation's initialOpen()attempts (OpenHedging::kEnabled) when hedging is active (!IsTotalBudgetSpent()), while keeping subsequentObjectDescriptor::Read()calls, MSO standby streams, and background stream resumes unhedged and untagged (OpenHedging::kDisabled). Note that any initial ranges passed viaReadRangesOptionare carried ininitial_requeston each hedgedOpen()attempt.options.h,async/client.h,connection_impl_open_test.cc):AsyncClient::Open()support (includingReadRangesOptionbehavior) onEnableReadHedgingOption,MaxTotalHedgesOption,ReadHedgeDelayOption,MaxReadHedgesOption, andAsyncClient::Open(), and marks sync-only options (MaximumHedgeBufferOption,ReadThreadPoolSizeOption,HedgingThreadPoolSizeOption) as ignored byAsyncClient::Open().OpenHedgingTest/OpenHedgingRescueTest/OpenHedgingConcurrentCompletionRacecovering gating & per-call overrides, fast-primary timer cancellation + unhedged MSO standby, slow-primary hedge win + unhedged background resume, primary win after hedge dispatch,kAbortedredirect & stall-timeout (kCancelled) rescues, permanent failure abort from either primary (PrimaryPermanentFailureAbortsInFlightHedge) or hedge (HedgePermanentFailureAbortsStalledPrimary), all-attempts-fail primary error precedence, caller.cancel(),MaxConcurrentHedgesOption/MaxTotalHedgesOptioncontention & lifetime exhaustion,x-goog-storage-cpp-featureskReadHedgingscoping (FeatureHeaderSetOnlyOnHedgedOpenAttempts), and multi-threaded completion races.